package com.fbs.wowo.message.mapper;

import com.fbs.wowo.message.entity.UserMsg;
import org.apache.ibatis.jdbc.SQL;

public class UserMsgSqlProvider {

    public String insertSelective(UserMsg record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("user_msg");
        
        if (record.getUmid() != null) {
            sql.VALUES("umid", "#{umid,jdbcType=VARCHAR}");
        }
        
        if (record.getUserId() != null) {
            sql.VALUES("user_id", "#{userId,jdbcType=VARCHAR}");
        }
        
        if (record.getMsgType() != null) {
            sql.VALUES("msg_type", "#{msgType,jdbcType=TINYINT}");
        }
        
        if (record.getEntityType() != null) {
            sql.VALUES("entity_type", "#{entityType,jdbcType=TINYINT}");
        }
        
        if (record.getEntityId() != null) {
            sql.VALUES("entity_id", "#{entityId,jdbcType=VARCHAR}");
        }
        
        if (record.getStatus() != null) {
            sql.VALUES("status", "#{status,jdbcType=TINYINT}");
        }
        
        if (record.getCreateTime() != null) {
            sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getMsgContent() != null) {
            sql.VALUES("msg_content", "#{msgContent,jdbcType=LONGVARCHAR}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(UserMsg record) {
        SQL sql = new SQL();
        sql.UPDATE("user_msg");
        
        if (record.getUserId() != null) {
            sql.SET("user_id = #{userId,jdbcType=VARCHAR}");
        }
        
        if (record.getMsgType() != null) {
            sql.SET("msg_type = #{msgType,jdbcType=TINYINT}");
        }
        
        if (record.getEntityType() != null) {
            sql.SET("entity_type = #{entityType,jdbcType=TINYINT}");
        }
        
        if (record.getEntityId() != null) {
            sql.SET("entity_id = #{entityId,jdbcType=VARCHAR}");
        }
        
        if (record.getStatus() != null) {
            sql.SET("status = #{status,jdbcType=TINYINT}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getMsgContent() != null) {
            sql.SET("msg_content = #{msgContent,jdbcType=LONGVARCHAR}");
        }
        
        sql.WHERE("umid = #{umid,jdbcType=VARCHAR}");
        
        return sql.toString();
    }
}